class Membership < ActiveRecord::Base
	
	stampable
	
	belongs_to :group
	belongs_to :user
	belongs_to :role
	
  validates_uniqueness_of   :user_id, :scope => :group_id, :message => 'User already belongs to group'
  validates_presence_of     :group, :user, :role

	after_create :delete_invitation
	
	def delete_invitation
    # when a membership is created, destroy that invitation
    #invitation = Invitation.find(:group => self.group, :email => self.user.email)
    #invitation.destroy
	end
	
	


end
